#include <cstdio>
using namespace std;

#define maxn 200001

int per[maxn][2];
int s[maxn*3],e[maxn*3],c[maxn*3];

int value[maxn];

void init(int start, int end, int u)
{
    if (start == end)
    {
        s[u] = start;
        e[u] = end;
        c[u] = 1;
    }
    else
    {
        s[u] = start;
        e[u] = end;
        c[u] = end-start+1;
        int mid = (start+end)/2;
        init(start,mid,2*u);
        init(mid+1,end,2*u+1);
    }
}

void change(int first,int second,int u)
{
    c[u]--;
    if (s[u] == e[u])
    {
        value[s[u]] = second;
        return;
    }
    if (c[u*2] > first)
    {
        change(first,second,u*2);
    }
    else
    {
        change(first - c[u*2],second,u*2+1);
    }
}

int main()
{
	freopen("test.in","r",stdin);
    int n;
    while (scanf("%d",&n)!=EOF)
    {
        int i;
        init(1,n,1);
        for (i = 0; i < n; ++i)
            scanf("%d %d", &per[i][0], &per[i][1]);
        for (i = n-1; i >= 0; --i)
            change(per[i][0],per[i][1],1);
        for (i = 1; i < n; ++i)
            printf("%d ", value[i]);
        printf("%d\n",value[i]);
    }
    return 0;
}

